/**
 * 发布到npm仓库
 * 1. 经过构建步骤
 * 2. 发布
 */
import { execSync as exec } from 'node:child_process'
import path from 'node:path';

exec(`npm run build`, { stdio: 'inherit' })


// 设置为官方仓库
exec(`npm config set registry https://registry.npmjs.org/`, { stdio: 'inherit' })

// 设置发布命令
let command = 'npm publish --access public';
// 执行发布命令，并将当前工作目录设置为dist目录
exec(command, { stdio: 'inherit', cwd: path.join(process.cwd(), 'dist') });

// 还原为taobao镜像仓库
exec(`npm config set registry https://registry.npm.taobao.org`, { stdio: 'inherit' })
